package com.rosense.srpingboot.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import com.rosense.srpingboot.dao.UserLogRepository;
import com.rosense.srpingboot.dao.UserMapper;
import com.rosense.srpingboot.entity.UserEntity;
import com.rosense.srpingboot.entity.UserLog;
import com.rosense.srpingboot.service.IUserService;

/**
 * 
 * @author 李岩飞
 * @email eliyanfei@126.com
 * @date 2018年3月10日 下午6:11:09
 */
@Service
public class UserServiceImpl implements IUserService {
	@Autowired
	private UserMapper userMapper;
	@Autowired
	private UserLogRepository userLogRepository;

	@Override
	public List<UserEntity> list() {
		return userMapper.list();
	}

	@Override
	public List<UserLog> listlog() {
		return userLogRepository.findAll(new PageRequest(0, 10, new Sort(Sort.Direction.DESC, "id"))).getContent();
	}

	@Override
	public UserEntity get(String account, String password) {
		return userMapper.get(account, password);
	}

	@Override
	public void saveLog(UserLog log) {
		this.userLogRepository.save(log);
	}
}
